//
//  UIViewController+NavRegister.m
//  LuxuryGoods
//
//  Created by 刘星辰 on 2018/5/19.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "UIViewController+NavRegister.h"
#import <objc/runtime.h>
#import "LGImageManagerIO.h"
@implementation UIViewController (NavRegister)
- (void)setHiddenNavigationBar:(BOOL)hiddenNavigationBar
{
    objc_setAssociatedObject(self, @selector(hiddenNavigationBar), @(hiddenNavigationBar), OBJC_ASSOCIATION_ASSIGN);
}

- (BOOL)hiddenNavigationBar
{
    NSNumber *number = objc_getAssociatedObject(self, _cmd);
    return [number boolValue];
}



- (void)setTransformStatusBarStyle:(BOOL)transformStatusBarStyle
{
    objc_setAssociatedObject(self, @selector(transformStatusBarStyle), @(transformStatusBarStyle), OBJC_ASSOCIATION_ASSIGN);
}

- (BOOL)transformStatusBarStyle
{
    NSNumber *number = objc_getAssociatedObject(self, _cmd);
    return [number boolValue];
}


- (void)lg_changeNavigationBarWithWhiteColor {
    [self lg_changeNavigationColor:[UIColor whiteColor] deleteBottomLine:YES];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
}

- (void)lg_changeNavigationColor:(UIColor *)color
                deleteBottomLine:(BOOL)deleteLine {
    [self.navigationController.navigationBar setBackgroundImage:[LGImageManagerIO createImageWithColor:color]
                                                  forBarMetrics:0];
    if (deleteLine) {
        self.navigationController.navigationBar.shadowImage = [UIImage new];
    } else {
        self.navigationController.navigationBar.shadowImage = nil;
    }
}

- (void)lg_deleteNavigationBarBottomLine {
    self.navigationController.navigationBar.shadowImage = [UIImage new];
}

- (void)lg_changeNavigationClearColor {
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    //    UIImage *image = [UIImage gp_imageWithColor:[UIColor whiteColor] alpha:0.0];
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
}

- (void)lg_setStatusBarStyle:(UIStatusBarStyle)style {
    [[UIApplication sharedApplication] setStatusBarStyle:style animated:YES];
}

- (void)lg_setNavigationTitleColor:(UIColor *)color {
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : color}];
}

@end
